package com.app.xinfadi.ui.user;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.app.xinfadi.R;
import com.app.xinfadi.base.BaseActivity;
import com.app.xinfadi.util.AppUtils;
import com.app.xinfadi.util.SharedPreferencesUtil;
import com.app.xinfadi.util.Toast;
import com.app.xinfadi.widget.SlidButton;


/**
 * 设置
 *
 * @author WuTengFei
 * @date 2014-11-30 下午10:35:18 <br/>
 */
public class UserSettingActivity extends BaseActivity {
    private String TAG = "UserSettingActivity";
    private AlertDialog.Builder builder;
    private SlidButton user_set_now_message;
    // 退出程序
    private Button exit_app;
    private TextView layout_app_version_title;
    private TextView layout_app_version;
    private ProgressBar progress_loading;
    private TextView user_suggestion_tv;
    private TextView about_tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.user_setting);
        initToolbar();
        initView();
    }

    private void initToolbar() {
        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        mToolbar.setTitle("设置");
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    protected void initView() {
        builder = new AlertDialog.Builder(this).setTitle("系统提示")
                .setPositiveButton("取消", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(getApplicationContext(), "11", Toast.LENGTH_SHORT).show();
                    }

                }).setNegativeButton("确定", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(getApplicationContext(), "确定", Toast.LENGTH_SHORT).show();
                    }

                });

        exit_app = (Button) findViewById(R.id.exit_app);
        exit_app.setOnClickListener(this);
        about_tv = (TextView) findViewById(R.id.about_tv);
        about_tv.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);// 退出程序
        switch (v.getId()) {
            case R.id.exit_app:
                // Toast.makeText(context, "已经退出当前账户", Toast.LENGTH_SHORT).show();
//                SharedPreferencesUtil.getInstance().saveUserState(0);
//                Intent intent = new Intent();
//                intent.setAction(MainActivity.MESSAGE_EXIT);
//                context.sendBroadcast(intent);
//                Intent userLoginIntent = new Intent(context, UserLogInActivity.class);
//                startActivity(userLoginIntent);
//                finish();
//                exitPorgress();
                exitPorgress();
                finish();
                break;
            case R.id.about_tv:
                Intent userAboutIntent = new Intent(context, UserAboutActivity.class);
                startActivity(userAboutIntent);
                break;
            default:
                break;
        }

    }
}
